<?php
	$keys = array_keys($_POST);
	$move_ids = array();
	foreach ($keys as $ids){
		if (strstr($ids, "item")){
			$move_ids[] = substr($ids, 5);
			$at_least_one = true;
		}
	}

	if ($at_least_one != true){
		oyster_log("ERROR", (string)$language->errors->value_22, "MonaLisa move_new");
		$head->_template_assign("ERROR", (string)$language->errors->value_22);
	} else {	
		$expo_old = sqlite_open($_GET["expo"]);
		$move = array();
		foreach ($move_ids as $id){
				$read_old = sqlite_array_query($expo_old, "SELECT * FROM expo WHERE (id='".$id."')", SQLITE_ASSOC);
				$delete = sqlite_query($expo_old, "DELETE FROM expo WHERE (id='".$id."')");
				$move[] = $read_old;
		}
		
		$expo_name_new = "./Applications/monalisa/Expositions/Expo.expo";
		
		if (file_exists($expo_name_new)){
			$expo_name_new = don3_plus_one("Expo.expo", "./Applications/monalisa/Expositions/");
		}
		
		$expo_new = sqlite_open($expo_name_new, 0666);
		$now = time();
		$write = sqlite_query($expo_new, 
					"CREATE TABLE expo(
						id INTEGER NOT NULL PRIMARY KEY,
						exhibit longtext,
						type VARCHAR(6))");
		$write .= sqlite_query($expo_new, "INSERT INTO expo (exhibit, type) VALUES ('Neue Ausstellung', 'desc')");
		$write .= sqlite_query($expo_new, "INSERT INTO expo (exhibit, type) VALUES ('$now', 'date')");
		foreach ($move as $neighbor){
			$xibit = $neighbor[0]['exhibit'];
			$type = $neighbor[0]['type'];
			$write .= sqlite_query($expo_new, "INSERT INTO expo (exhibit, type) VALUES ('$xibit', '$type')");
		}
		sqlite_close($expo_old);
		sqlite_close($expo_new);
	}
?>